package com.dyz.leetcode;

public class HammingDistance461 {
    //方法一使用bitcount
    public int hammingDistance(int x, int y) {

        int z = x ^ y;
        int res = Integer.bitCount(z);
        return res;

    }
    private int bitCount(int i){
        int count=0;
        while (i>0){
            if(i%2==1){
                count++;
            }
            i = i>>1;
        }
        return count;
    }
}
